package design_pattern.ActiveObjects;

/**
 * @Author: 蔡翔
 * @Date: 2019/11/27 16:12
 * @Version 1.0
 */
public class ActiveObjectProxy implements ActiveObject{

    private final SchedualerThread schedualerThread;

    private final Servant servant;

    public ActiveObjectProxy(SchedualerThread schedualerThread, Servant servant) {
        this.schedualerThread = schedualerThread;
        this.servant = servant;
    }

    @Override
    public Result makeString(int count, char fillChar) {
        FutureResult futureResult = new FutureResult();
        schedualerThread.invoke(new MakeStringRequest(servant,futureResult,count,fillChar));
        return futureResult;
    }

    @Override
    public void displayString(String text) {
        schedualerThread.invoke(new DisplayStringRequest(servant , text));
    }
}